
<!-- 保修保养业务汇总 -->
<template>
    <div>
 <TopFilter ref="TopFilterss" :list="topFilterInit" :cols="4" :collapse="collapse" labelWidth="110" @filterChange="changeHandle"></TopFilter>
    <FilterTable
      ref="table"
      :columns="columns"
      :params="fetchParams"
      :fetchapi="fetchapi"
      :datakey="'records'"
      :onColumnsChange="columns => (this.columns = columns)"
      :is-select-column="false"
      :onRowSelectChange="selectChange"
      >
     
        <template slot="controls" slot-scope="props">
        <multiuse-button type="primary" :click="exportFileBtn.bind()">导出</multiuse-button>
      </template>
      </FilterTable>
      <BaseDialog :visible.sync="selectDelearFlag" :title="'经销商选择'" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <DealerList @close="Delearclose" @save="Delearsave"></DealerList>
      </BaseDialog>
      </div>
</template>

<script>
import moment from "moment";
import DealerList from '@/pages/claimDemage/tools/DealerList.vue';
import {getListByPage, getListForExport,exporturl} from '@/api/claim/factory/WarrantyMaintenanceManage';
import { exportExcelFile } from '@/utils/index';
    export  default{
        components: {
        DealerList
        },
        data(){
            return{
                topFilterInit: this.topFilterInitFun(),
                fetchParams: { xhrAbort: true },    
                selectDelearFlag: false,
                collapse: true,
                columns: this.creatHeader(),
                fetchapi: getListByPage
            };

        },

    methods:{
    //选中
    selectChange(rows) {
    //   this.selectedRows = rows;
    //   this.disableds = this.selectedRows.length <= 0;
    //   console.log(this.selectedRows);
    },
    // 导出
    async exportFileBtn() {
      let json = Object.assign({}, { CODE: 'CODE_00000149' }, this.fetchParams);
      let res = await exporturl(json);
      if (res.resultCode == 200) {
        this.$router.push('/admin/auth/oem/downloadCenter');
      }
      // getListForExport(this.fetchParams).then(res => {
      //   exportExcelFile(res.data, '保修保养业务汇总表');
      // });
    },
    SelectDelear() {
      this.selectDelearFlag = true;
    },//关闭
    Delearclose() {
      this.selectDelearFlag = false;
    },
    //保存
    Delearsave(obj) {
      this.topFilterInit.map(x => {
        if ('ownerCode' == x.fieldName) {
          x.initialValue = obj[0].dealerCode; //维修工单号返显
        }
      })
      this.selectDelearFlag = false;

    },
    //搜索获取数据
    changeHandle(val) {
      /*刷新表格 用它*/
      this.fetchParams = Object.assign({}, this.fetchParams, val,{xhrAbort:false});
      console.log(this.fetchParams);
    },
    //搜索数据
    topFilterInitFun() {
      return [
        {
          type: 'INPUT',
          label: '服务站代码',
          fieldName: 'ownerCode',
          placeholder: '请输入',
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.SelectDelear()} />
              </div>
            );
          }
        },
         {
          type: 'INPUT',
          label: '服务站名称',
          fieldName: 'dealerName',
          placeholder: '',
          initialValue: '',
          
        },
        { type: 'RANGE_DATE', label: '结算单生成时间', fieldName: 'statementGenerationTimeStar|statementGenerationTimeEnd', placeholder: '请输入',initialValue: [
            moment()
              .startOf('week')
              .format('YYYY-MM-DD HH:mm:ss'),
            moment()
              .endOf('week')
              .format('YYYY-MM-DD HH:mm:ss')
          ],
          rules: [{ required: true, message: '请选择日期', trigger: 'change' }] },
        { type: 'RANGE_DATE', label: '发票到达时间', fieldName: 'invoiceReviewTimeStar|invoiceReviewTimeEnd', placeholder: '请输入',initialValue: [
            moment()
              .startOf('week')
              .format('YYYY-MM-DD HH:mm:ss'),
            moment()
              .endOf('week')
              .format('YYYY-MM-DD HH:mm:ss')
          ] },
        { type: 'INPUT', label: '索赔单号', fieldName: 'claimNo', placeholder: '请输入', initialValue: '' }
      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '索赔类型', dataIndex: 'cmsClaimTypeForSelect', sorter: true },
        { title: '索赔二级分类', dataIndex: 'batchName', sorter: true },
        { title: '索赔单号', dataIndex: 'claimNo', sorter: true },
        { title: '服务站代码', dataIndex: 'dealerCode', sorter: true },
        {
              title: '服务站全称',
              dataIndex: 'dealerName',
              sorter: true
        },
        { title: 'VIN', dataIndex: 'vin', sorter: true },
        { title: '故障代码', dataIndex: 'supCode', sorter: true },
        { title: '维修开始日期', dataIndex: 'serviceBeginDate', sorter: true,dateFormat:'yyyy-MM-dd HH:mm:ss'},
        { title: '祸首件代码', dataIndex: 'partCode', sorter: true },
        { title: '祸首件名称', dataIndex: 'partName', sorter: true },
        { title: '维修内容', dataIndex: 'cmsClaimPgm', sorter: true },
        { title: '备件金额', dataIndex: 'partAmount', sorter: true },
        { title: '维修工时金额', dataIndex: 'labourAmount', sorter: true },
        { title: '外出服务金额', dataIndex: 'helpAmount', sorter: true },
        { title: '备件管理费', dataIndex: 'partglFare', sorter: true },
        { title: '备件运费', dataIndex: 'partFare', sorter: true },
        { title: '其他费用金额', dataIndex: 'addAmount', sorter: true },
        { title: '批准金额', dataIndex: 'claimSumAmount', sorter: true },
        { title: '单据状态', dataIndex: 'statusStr', sorter: true },
        { title: '考核金额', dataIndex: 'assessAmount', sorter: true },
        { title: '考核原因', dataIndex: 'assessReason', sorter: true },
        { title: '开票金额', dataIndex: 'invoiceSum', sorter: true },
        {
          title: '开户银行名称',
          dataIndex: 'bankName',
          sorter: true,
   
        },
         { title: '银行行号', dataIndex: 'yhhh', sorter: true },
         { title: '收款账号', dataIndex: 'skzh', sorter: true },
         {title: '纳税人识别号', dataIndex: 'taxpayerIdentityNumber', sorter: true },
         {title: '电话', dataIndex: 'ncvmobilen', sorter: true },
         {title: '地址', dataIndex: 'adress', sorter: true }

      ];
    },
        }
    };
 </script>
<style lang="less" scoped></style>   
